/*
 * Copyright (C) 2023 Coder.AN
 * Email: an.hongjun@foxmail.com
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */
#ifndef __EDGE_TENSOR_KERNEL_H__
#define __EDGE_TENSOR_KERNEL_H__

#include "edge_tensor.h"
using namespace tensor;

#ifdef __cplusplus
extern "C" {
#endif

// resize
void Resize(const uint8_t* src, uint8_t* dst, Dim old_dim, Dim new_dim, 
                DimOrder dim_order, size_t unit_count);

// rect
void Rect(const void* src, void* dst, int delta_w, int delta_h, int new_w, int new_h,
            Dim old_dim, DimOrder dim_order, size_t unit_size, size_t unit_count);

// transpose
void Transpose(const void* src, void* dst, DimOrder src_ord, DimOrder dst_ord,
               Dim dim, size_t unit_size, size_t unit_count);

// convert_type
void ConvertUint8ToFloat32(const uint8_t* src, float* dst, size_t unit_count);
void ConvertInt32ToUint8(const int32_t* src, uint8_t* dst, size_t unit_count);

// convert_color
void ConvertBGRToRGB(const uint8_t* src, uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order);
void ConvertBGRToGray(const uint8_t* src,uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order);
void ConvertRGBToBGR(const uint8_t* src, uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order);
void ConvertRGBToGray(const uint8_t* src, uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order);
void ConvertGrayToBGR(const uint8_t* src, uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order);
void ConvertGrayToRGB(const uint8_t* src, uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order);

// concat
void HConcat(const void* src_l, const void* src_r, void* dst, size_t unit_count, size_t unit_size, 
                Dim dim_l, Dim dim_r, DimOrder dim_order);
void VConcat(const void* src_u, const void* src_d, void* dst, size_t unit_count, size_t unit_size, 
                Dim dim_u, Dim dim_d, DimOrder dim_order);

// flip
void HFlip(const void* src, void* dst, Dim dim, DimOrder dim_order, size_t unit_size, size_t unit_count);
void VFlip(const void* src, void* dst, Dim dim, DimOrder dim_order, size_t unit_size, size_t unit_count);

// normalize
void NormalizeFloat32(const float* src, float* dst, size_t unit_count);
void NormalizeFloat64(const double* src, double* dst, size_t unit_count);

// draw
void DrawGrayLine(uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order, 
                    uint8_t grayVal, int x_min, int x_max, int y_min, int y_max, int A, int B, int C, int r);
void DrawColorLine(uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order,
                    Color colorVal, int x_min, int x_max, int y_min, int y_max, int A, int B, int C, int r);
void DrawGrayCircle(uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order,
                        Point center, uint8_t grayVal, int r2);
void DrawColorCircle(uint8_t* dst, size_t unit_count, Dim dim, DimOrder dim_order,
                        Point center, Color colorVal, int r2);

// tools for segmentation
void MapSegRes(const uint8_t* src, uint8_t* dst, size_t unit_count, std::vector<uint8_t> map_list);

#ifdef __cplusplus
}
#endif

#endif // __EDGE_TENSOR_KERNEL_H__